import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import '../../pages/station/station_info_edit.dart';
import '../../helper/routeHelper.dart';
import '../../helper/uidata.dart';
import '../../pages/station/station_helper.dart';
import '../../widgets/inputWidget.dart';
import '../../helper/global_config.dart';

import '../../model/station.dart';
import '../../widgets/IconWidget.dart';

class StationInfoPage extends StatelessWidget {
  @override
  StationInfoPage(this.s1);
  final Station s1;

  List<Widget> getAllWidget(BuildContext context) {
    List<Widget> list1 = <Widget>[];
    List<Widget> list2 = <Widget>[];
    List<Widget> list3 = <Widget>[];

    list1.add(InputWidget.inCard(
      ListTile(
        leading: IconWidget.RiverImage(),
        title: Text("基础信息"),
        onTap: StationHelper.IfGuanLi(UIData.CurrentUser!)
            ? () {
                RouteHelper.ShowPage(
                    context, StationInfoEditPage(s1, () => {}));
              }
            : null,
      ),
    ));

    list2.add(InputWidget.getInfo("所属河流", s1.River));
    list2.add(Divider(
      height: 0.0,
    ));
    list2.add(InputWidget.getLocationTile(
        context, "所在位置", s1.Location, s1.LTTD, s1.LGTD));
    list2.add(Divider(
      height: 0.0,
    ));
    list2.add(InputWidget.getInfo("观测项目", s1.STTP));
    //list2.add(Divider(height: 0.0,));
    list1.add(InputWidget.inCard2(list2));

    list3.add(InputWidget.getInfo("测站站号", s1.Code.toString()));
    list3.add(Divider(
      height: 0.0,
    ));
    // list3.add(InputWidget.getInfo("短信号码", s1.DuanXin));
    list3
        .add(InputWidget.getUserTile2(context, "短信号码", s1.DuanXin, s1.DuanXin));
    list3.add(Divider(
      height: 0.0,
    ));
    list3.add(InputWidget.getInfo("卫星号码", s1.WeiXing));
    list3.add(Divider(
      height: 0.0,
    ));
    list3.add(
        InputWidget.getUserTile2(context, "看管人", s1.ManaName, s1.ManaPhone));
    list1.add(InputWidget.inCard2(list3));

    //list1.add(InputWidget.getQMTile(s1.State==6, Helper.DateTimeFormat(s1.HZQMTM), s1.HZQM));
    return list1;
  }

  @override
  Widget build(BuildContext context) {
    if (s1 == null) return new Container();

    // TODO: implement build
    return SingleChildScrollView(
      child: new Container(
          margin: EdgeInsets.only(top: 4.0),
          child: new Column(children: getAllWidget(context))),
    );
  }
}
